package org.aceor.mddal.config.sharding;

import org.aceor.mddal.common.sharding.ShardingFunction;

/**
 * table分表规则
 * Created by lxue on 16/3/26.
 */
public class DBShardingFunction1 extends AbstractShardingFunction implements ShardingFunction {
    @Override
    public String getShardingColumn() {
        return "id";
//        return null;
    }

    @Override
    public Number getStep() {
        return 1;
    }

    @Override
    public int getMaxStepCounts() {
        return 20;
    }

    @Override
    public LinearMeasure getLinearMeasure() {
        return LinearMeasure.NUMBER;
    }

    @Override
    protected int doExecuteSharding(Long originValue) {
        Long result = originValue % 2;
        System.out.println("分库编号 :"+result);
        return result.intValue();
    }
}
